var gulp=require('gulp');
var gulpif=require('gulp-if');
var rev=require('gulp-rev');
var revReplace=require('gulp-rev-replace');
var revCollector=require('gulp-rev-collector');

gulp.task('release:pre', function() {
    return gulp.src('dist/compile/**/*')
        .pipe(gulp.dest('dist/release'));
});

gulp.task('release:rev:pre', function() {
    return gulp.src(['dist/compile/**/*.js','dist/compile/**/*.css','dist/compile/**/image/*'])
        .pipe(rev())
        .pipe(gulp.dest('dist/release'))
        .pipe(rev.manifest())
        .pipe(gulp.dest('dist/release'));
});

gulp.task('release:rev',['release:rev:pre','release:pre'], function() {
    return gulp.src(['dist/release/rev-manifest.json','dist/compile/*.html'])
        .pipe(revCollector())
        .pipe(gulp.dest('dist/release'));
});

gulp.task('release',['release:rev'], function() {
    return gulp.src(['dist/release/**/*'])
        .pipe(gulp.dest('../server/src/main/resources/META-INF/resources/app'));
});